package com.yutian.example.demo.common.utils;

import com.yutian.example.demo.common.exceptions.MyParamException;
import org.apache.commons.lang.StringUtils;

public class AssertParamUtil {

    public static void isTrue(boolean expression, String message) {
        isTrue(expression, message, null);
    }

    public static void notNull(Object object, String message) {
        notNull(object, message, null);
    }

    public static void notBlank(String text, String message) {
        notBlank(text, message, null);
    }

    public static void isTrue(boolean expression, String message, String[] params) {
        if (!expression) {
            throw new MyParamException(message, params);
        }
    }

    public static void notNull(Object object, String message, String[] params) {
        if (object == null) {
            throw new MyParamException(message, params);
        }
    }

    public static void notBlank(String text, String message, String[] params) {
        if (StringUtils.isBlank(text)) {
            throw new MyParamException(message, params);
        }
    }
}
